package com.fanshuai2.niuke.dynamic;

import java.util.Scanner;

public class HeiZhuang {
    static int getMax(int[] weight) {
        int len = weight.length;

        int[] dp = new int[len];
        for (int i = 0; i < len; i++) {
            dp[i] = 1;
        }
        for (int i = len - 2; i >= 0; i--) {
            for (int j = len - 1; j >i; j--) {
                if (weight[i] < weight[j] && dp[i] < dp[j] + 1) {
                    dp[i] = dp[j] + 1;
                }
            }

        }
        int max = -1;
        for (int i = 0; i < len; i++) {
            if (dp[i] > max) {
                max = dp[i];
            }
        }
        return max;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt();
            int[] weight = new int[n];
            for (int i = 0; i < n; i++) {
                weight[i] = in.nextInt();
            }

            System.out.println(getMax(weight));
        }
    }
}
